<div class="am-g">
    <!-- Row start -->
    <div class="am-u-sm-12">
        <div class="card-box">
            <form action="" class="am-form" method="post" data-am-validator id="doc-vld-msg">
                <fieldset>
                    <input type="hidden" name="id" value="{{.Sdata.Id}}" class="am-form-field"/>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">产品名称：</label>
                        <input type="text" name="name" value="{{.Sdata.Name}}"  class="am-form-field"/>
                    </div>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">产品规格：</label>
                        <input type="text" name="spec" value="{{.Sdata.Spec}}"  class="am-form-field"/>
                    </div>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">产品型号：</label>
                        <input type="text" name="gmodel" value="{{.Sdata.Gmodel}}"  class="am-form-field"/>
                    </div>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">产品单位：</label>
                        <input type="text" name="units" value="{{.Sdata.Units}}"  class="am-form-field"/>
                    </div>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">产品价格：</label>
                        <input type="text" name="price" value="{{.Sdata.Price}}"  class="am-form-field"/>
                    </div>
                    <div class="am-form-group">
                        <label>是否有效： </label>
                        <label class="am-radio-inline">
								        <input type="radio" {{if eq .Sdata.Status 0}} checked {{end}}value="0" name="status" required> 有效
								      </label>
                        <label class="am-radio-inline">
								        <input type="radio"  {{if eq .Sdata.Status 1}} checked {{end}} value="1" name="status"> 无效
								      </label>
                    </div>
                    <div class="am-form-group">
                        <label>销售状态： </label>
                        <label class="am-radio-inline">
								        <input type="radio" {{if eq .Sdata.SaleStatus 0}} checked {{end}}  value="0" name="salestatus" required> 可售
								      </label>
                        <label class="am-radio-inline">
								        <input type="radio"  {{if eq .Sdata.SaleStatus 1}} checked {{end}}  value="1" name="salestatus"> 不可售
								      </label>
                    </div>

                    <div class="am-form-group">
                        <label>产品分类一级</label>
                        <select id="doc-select-1">
                            {{range .ol}}
                            <option value="{{.Id}}">{{.Name}}</option>
                            {{end}}
                        </select>
                        <span class="am-form-caret"></span>
                    </div>
                    <div class="am-form-group">
                        <label>产品分类二级</label>
                        <select id="doc-select-2" name="sorteid">
                            {{range .tl}}
                            <option {{if eq $.Sdata.Sorteid .Id}} selected="selected" {{end}} value="{{.Id}}">{{.Name}}</option>
                            {{end}}
                        </select>
                        <span class="am-form-caret"></span>
                    </div>
                    <button class="am-btn am-btn-secondary" type="button">提交</button>
                </fieldset>
            </form>


        </div>
    </div>
    <!-- Row end -->
</div>
</div>
</div>
<script>
    var _url = "/sorts/ajaxlist"
    $("#doc-select-1").change(function(){
        var pid=$(this).val()
         $.get(_url, { pid: pid}, function (data) {
                    if (data.status == 1) {
                        var _html=""
                        for (var index = 0; index < data.tl.length; index++) {
                            var s=data.tl[index];
                            _html=_html+'<option value="'+s.Id+'">'+s.Name+'</option>';
                        }
                        $("#doc-select-2").html(_html)
                    } else {
                        var _html=""
                         $("#doc-select-2").html(_html)
                    }
                },"json")
    });
    $(".am-btn").click(function(){
        $.post("/goods/add",$("form").serializeArray(),function(data){
            if(data.status==1){
                 if (confirm("添加成功,是否继续添加产品？")) {
                     window.location.reload();
                 }else{
                     window.location.href=data.url;
                 }
            }else{
                alert(data.msg);
            }
        })
    });

</script>